<!DOCTYPE html>
<html lang="en">

<head>

    <script src="js/echart3.js"></script>
    <script src="js/echarts-wordcloud.js"></script>

    <title>Echarts案例词云图</title>
</head>

<body>
    <div style="height:600px;width:600px;" id="word_cloud"></div>
</body>
<script>
    function echarts_1() {
        var myChart = echarts3.init(document.getElementById('word_cloud'));

        let all_data = [{ name: "轮机工程", value: 121 }, { name: "航海技术", value: 71 }, { name: "法学", value: 90 }, { name: "交通运输类", value: 85 }, { name: "机械类", value: 54 }, { name: "工商管理类", value: 35 }, { name: "公共管理类", value: 34, }, { name: "自动化类", value: 22 }, { name: "电子信息类", value: 21 }, { name: "安全工程", value: 21 }, { name: "计算机类", value: 15 }, { name: "日语", value: 15 }, { name: "交通管理", value: 11 }, { name: "政治学与行政学", value: 9 }, { name: "	数学", value: 9 }, { name: "公共事业管理", value: 9 }, { name: "电子商务", value: 9 }, { name: "英语", value: 8 }, { name: "经济类", value: 8 }, { name: "土木工程", value: 7 }]

        let option = {
            title: {
                text: '词云图',
                // link: 'https://www.baidu.com/s?wd=' + encodeURIComponent('ECharts'),
                x: 'center',
                textStyle: {
                    fontSize: 26
                }
            },
            //backgroundColor: '#F7F7F7',
            tooltip: {
                show: true
            },
            toolbox: {
                feature: {
                    saveAsImage: {
                        iconStyle: {
                            normal: {
                                color: '#FFFFFF'
                            }
                        }
                    }
                }
            },
            series: [{
                name: '热点分析',
                type: 'wordCloud',
                size: ['9%', '99%'],
                sizeRange: [10, 60],
                //textRotation: [0, 45, 90, -45],
                rotationRange: [0, 0],
                //shape: 'circle',
                textPadding: 0,
                autoSize: {
                    enable: true,
                    minSize: 0
                },
                textStyle: {
                    normal: {
                        color: function (params) {
                            //注意，如果颜色太少的话，后面颜色不会自动循环，最好多定义几个颜色
                            var colorList = ['#5470c6', '#91cc75', '#fac858', '#ee6666', '#73c0de', '#3ba272', '#fc8452', '#9a60b4', '#ea7ccc', '#0e94eb', '#c440ef', '#efb013', '#FFD700', '#8470FF', '#2e4af8', '#0eebc4', '#f129b1', '#17defc', '#f86363'];
                            if (params.dataIndex >= colorList.length) {
                                index = params.dataIndex - colorList.length;
                            }
                            return colorList[params.dataIndex]
                        }
                    },
                    emphasis: {
                        shadowBlur: 10,
                        shadowColor: '#333'
                    }
                },
                data: all_data
            }]
        }

        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
        window.addEventListener("resize", function () {
            myChart.resize();
        });
    }
    echarts_1();
</script>

</html>